//
//  RegisteredController.m
//  QRBuildScan
//
//  Created by gongjie on 12-1-2.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "RegisteredController.h"
#import <QuartzCore/QuartzCore.h>

@implementation RegisteredController

@synthesize r_leftbuttn;
@synthesize r_rightbuttn;

//- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
//{
//    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
//    if (self) {
//        // Custom initialization
//    }
//    return self;
//}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView
{
}
*/

-(id)init{
    if (self = [ super init]) {

    }
    return self;

}
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
    [super viewDidLoad];
     [self.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"background.png"]]];
    r_Tableview = [[UITableView alloc] initWithFrame:CGRectMake(10, 10,300 ,200 ) style:UITableViewStyleGrouped];
    [r_Tableview setBackgroundColor:[UIColor clearColor]];
    [r_Tableview setDelegate:self];
    [r_Tableview setDataSource:self];
    [self.view addSubview:r_Tableview];

    r_rightbuttn= [UIButton buttonWithType:UIButtonTypeCustom];
    r_rightbuttn.frame = CGRectMake(250,7, 60, 30);
    [r_rightbuttn setBackgroundImage:[UIImage imageNamed:@"ok.png"] forState:UIControlStateNormal];
    [r_rightbuttn addTarget:self action:@selector(changRright) forControlEvents:UIControlEventTouchUpInside];
    
    r_leftbuttn = [UIButton buttonWithType:UIButtonTypeCustom];
    r_leftbuttn.frame = CGRectMake(10,7, 60, 30);
    [r_leftbuttn setBackgroundImage:[UIImage imageNamed:@"cancel.png"] forState:UIControlStateNormal];
    [r_leftbuttn addTarget:self action:@selector(changRleft) forControlEvents:UIControlEventTouchUpInside];
}



#pragma mark self
-(void)changRleft
{
    if (r_leftbuttn.superview) {
            [r_leftbuttn removeFromSuperview];
    }
    if (r_rightbuttn.superview) {
        [r_rightbuttn removeFromSuperview];
    }
    [self.navigationController popViewControllerAnimated:YES];
}
-(void)changRright
{

}
-(void)requestLogin:(NSString*)usename word:(NSString*)password
{
    
}
-(void)requestpageSuccess:(ASIHTTPRequest*)request
{
    
}
-(void)requestpageFailure:(ASIHTTPRequest*)request
{
    
}
#pragma mark UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 4;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UIView* tview = [[[UIView alloc] initWithFrame:tableView.frame] autorelease];
	[tview setBackgroundColor:[UIColor clearColor]];
	[tableView setBackgroundView:tview];
    static NSString *CellIdentifier = @"Cell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
        cell.selectionStyle =UITableViewCellSelectionStyleNone;
        NSUInteger row = [indexPath row];
        if (row == 0) {
            if (r_Usename == nil) {
                r_Usename = [[UITextField alloc] initWithFrame:CGRectMake(10, 10, 200, 30)];
            }
            [r_Usename setBorderStyle:UITextBorderStyleNone];
            [r_Usename setPlaceholder:@"请输入您的名字"];
            [r_Usename setReturnKeyType:UIReturnKeyDone];
            [r_Usename setFont:[UIFont systemFontOfSize:20]];
            r_Usename.keyboardType = UIKeyboardTypeNamePhonePad;
            [cell.contentView addSubview:r_Usename];
        }
        else if(row == 1)
        {
            if (r_Usemail == nil) {
                r_Usemail = [[UITextField alloc] initWithFrame:CGRectMake(10, 10, 200, 30)];
            }
            [r_Usemail setBorderStyle:UITextBorderStyleNone];
            [r_Usemail setPlaceholder:@"请输入您的邮箱"];
            [r_Usemail setReturnKeyType:UIReturnKeyDone];
            [r_Usemail setFont:[UIFont systemFontOfSize:20]];
            r_Usemail.keyboardType = UIKeyboardTypeNamePhonePad;
            [cell.contentView addSubview:r_Usemail];
        }
        else if(row == 2)
        {
            if (r_Password == nil) {
                r_Password = [[UITextField alloc] initWithFrame:CGRectMake(10, 10, 200, 30)];
            }
            [r_Password setBorderStyle:UITextBorderStyleNone];
            [r_Password setPlaceholder:@"输入您的密码"];
            [r_Password setReturnKeyType:UIReturnKeyDone];
            [r_Password setFont:[UIFont systemFontOfSize:20]];
            r_Password.keyboardType = UIKeyboardTypeNamePhonePad;
            [cell.contentView addSubview:r_Password];
        }
        else if(row == 3)
        {
            if (r_passwords == nil) {
                r_passwords = [[UITextField alloc] initWithFrame:CGRectMake(10, 10, 200, 30)];
            }
            [r_passwords setBorderStyle:UITextBorderStyleNone];
            [r_passwords setPlaceholder:@"再次输入密码"];
            [r_passwords setReturnKeyType:UIReturnKeyDone];
            [r_passwords setFont:[UIFont systemFontOfSize:20]];
            r_passwords.keyboardType = UIKeyboardTypeNamePhonePad;
            [cell.contentView addSubview:r_passwords];
        }
        
        
    }
    return cell;
}

#pragma mark UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 40;
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
//    NSMutableArray* sectionarr= [[NSMutableArray alloc] init];
//    BOOL isAdd;
//    for (id object in listarr) {
//        isAdd = NO;
//        NSString* tGround =object.m_GroundI;
//        for (NSArray* groundsetionArr in sectionarr ) {
//            id groubobject =[groundsetionArr lastObject];
//            if ([groubobject.mGround isEqual:tGround]) {
//                <#statements#>
//                isAdd =YES;
//            }
//            
//        }
//        if (!isAdd) {
//            NSMutableArray* tGround =[[NSMutableArray alloc] init];
//            [tGround addObject:object];
//            [sectionarr addObject:tGround];
//        }
//    }
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
-(void)dealloc{
    [r_Tableview release];
    [r_Usename release];
    [r_Usemail release];
    [r_Password release];
    [r_passwords release];
    r_leftbuttn = nil;
    r_rightbuttn = nil;
    [super dealloc];
}
@end
